package com.springboot.hibernate.controller.system;

import com.springboot.hibernate.entity.Menu;
import com.springboot.hibernate.service.IMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 描 述: 描述
 *
 * @author 南瓜
 * @date: 2019/4/9
 */
@Controller
@RequestMapping("menu")
public class MenuController {
    
    @Autowired
    private IMenuService menuService;
    
    @RequestMapping("index")
    public String index() {
        return "menu/index";
    }
    
    @ResponseBody
    @RequestMapping("list")
    public Map list() {
        Map resultMap = new HashMap();
        List<Menu> menuListst = menuService.findPage(null);
        resultMap.put("total",menuListst.size());
        resultMap.put("rows" ,menuListst);

        return resultMap;
    }
    
    @ResponseBody
    @RequestMapping("save")
    public Boolean save(Menu menu) {
        menuService.save(menu);
        return false;
    }
}
